/**
 * BPMCaseLog
 *
 * new BPMCaseLog({
 *
 * });
 * ------------------------------------
 *
 * API:
 *-------------------------------------
 * fromXML(caseLogXml)
 * getStepList()
 *
 */
(function(global){

    'use strict';

    const logger = WorkflowUtil.newLogger("WorkflowApp/BPMCaseLog");

    let BPMCaseLog = function () {

        BPMCaseLog.__super__.constructor.apply(this, arguments);

        //初始化属性
        //this.addAttr("type", "", "t");

        // Step 列表
        this.stepList = [];
    };
    //继承
    WorkflowUtil.extend(BPMCaseLog, global.BPMObject);

    
    BPMCaseLog.prototype.getStepList = function(){
        return this.stepList;
    };
    
    /**
     * 解析XMLNode
     */
    BPMCaseLog.prototype.fromXML = function(caseLogXml){

        const root = WorkflowUtil.getXMLDoc(caseLogXml);
        let child = root.documentElement.firstChild;

        while (child != null){

            const step = new global.Step();
            step.fromXML(child);
            
            this.stepList.push(step);
            
            // 继续循环
            child = child.nextSibling;
        }
    };
    
    global.BPMCaseLog = BPMCaseLog;

})(WorkflowApp);


/**
 * Step
 * -----------------
 * 
 * API:
 * -----------------
 * getFrameList()
 * fromXML(xmlDom)
 */
(function(global){

    'use strict';

    const logger = WorkflowUtil.newLogger("WorkflowApp/Step");

    let Step = function () {

        Step.__super__.constructor.apply(this, arguments);

        //初始化属性
        this.addAttr("action", "", "A");
        this.addAttr("nodeId", "", "N");

        this.frameList = [];// ProcessFrame 列表
    };
    //继承
    WorkflowUtil.extend(Step, global.BPMObject);
    
    
    Step.prototype.getFrameList = function(){
        return this.frameList;
    };
    
    Step.prototype.fromXML = function(xmlDom){
        
        this.transXMLNode2BPMObject(xmlDom);

        let frameDoc = xmlDom.firstChild;
        while(frameDoc != null){

            const frame = new global.ProcessFrame();
            frame.fromXML(frameDoc);
            
            this.frameList.push(frame);
            
            //循环继续
            frameDoc = frameDoc.nextSibling;
        }
    };
    
    /**
     * 添加 ProcessFrame
     */
    Step.prototype.addFrame = function(frame){
        this.frameList.push(frame);
    };
    
    global.Step = Step;

})(WorkflowApp);



/**
 * ProcessFrame
 *
 * new ProcessFrame({
 *
 * });
 * ------------------------------------
 *
 * API:
 *-------------------------------------
 * 
 * fromXML(xmlDom)
 * getNodeId()
 * getState()
 */
(function(global){

    'use strict';

    const logger = WorkflowUtil.newLogger("WorkflowApp/ProcessFrame");

    let ProcessFrame = function () {

        ProcessFrame.__super__.constructor.apply(this, arguments);

        //初始化属性
        this.addAttr("nodeId", "", "N");
        this.addAttr("state", "", "S");
        this.addAttr("attri_1", "", "A1");
        this.addAttr("attri_2", "", "A2");
    };
    //继承
    WorkflowUtil.extend(ProcessFrame, global.BPMObject);
    
    
    ProcessFrame.prototype.fromXML = function(xmlDom){
        
        this.transXMLNode2BPMObject(xmlDom);
    };
    
    ProcessFrame.prototype.getState = function(){
        return this.getAttr("state");
    };
    
    ProcessFrame.prototype.getNodeId = function(){
        return this.getAttr("nodeId");
    };
    
    global.ProcessFrame = ProcessFrame;

})(WorkflowApp);
